<template>
  <div>
    <!-- 面包屑首页 -->
    <!-- separator-class是分隔符 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 渲染列表 -->
    
    <el-table :data="userdata" border style="width: 100%">
      <el-table-column type="index" width="50"> </el-table-column>
      <el-table-column prop="authName" label="权限姓名" width="180">
      </el-table-column>
      <el-table-column prop="path" label="路径"> </el-table-column>
      <el-table-column prop="level" label="等级">
        <!-- 利用插槽来访问子元素里边的值，使其状态改变 -->
        <template slot-scope="scope">
          <el-tag v-if="scope.row.level === '0'">一等</el-tag>
          <el-tag type="success" v-if="scope.row.level === '1'">二等</el-tag>
          <el-tag type="info" v-if="scope.row.level === '2'">三等</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  //权限列表
  data() {
    return {
      userdata: [],
    };
  },
  methods: {
    //获取权限列表的数据
    async UsersdataName() {
      let { data } = await this.$req.get("/rights/list");
      console.log(data);
      //判断状态成功
      if (data.meta.status == 200) {
        this.$message({
          message: data.meta.msg,
          type: "success",
        });
        //渲染页面
        this.userdata = data.data;
      } else {
        //判断状态失败
        this.$message.error(data.data.msg);
      }
    },
  },
  //在渲染页面之前就获取到数据
  async mounted() {
    this.UsersdataName();
  },
};
</script>

<style>
</style>